#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp(const void *a, const void *b) {
  int ai = *(int *)a, bi = *(int *)b;
  return ai-bi;
}

int cot[100], cht[100],  q[1000000];
double coq[100], chq[100];

  /* too lazy to read queries incrementally */

int coc, chc, qc;

int main () {
  char str[100];
  int time, i;
  double quant;
  coc = chc = qc = 0;
  while (scanf("%s", str) == 1) {
    if (!strcmp(str,"Query")) {
      scanf("%d", &time);
      quant = -1;
      q[qc++] = time;
    } else if (!strcmp(str,"Chocolate")) {
      scanf("%d%lf", &time, &quant);
      cht[chc] = time;
      chq[chc++] = quant;
    } else if (!strcmp(str,"Coffee")) {
      scanf("%d%lf", &time, &quant);
      cot[coc] = time;
      coq[coc++] = quant;
    }
  }
  qsort(q,qc,sizeof(int),cmp);
  for (i = 0; i < qc; i++) {
    double dist, dd;
    int c;
    dist = 0.0;
    for (c = 0; c < coc; c++) {
      if (cot[c] > q[i])
	continue;
      dd = 2*coq[c] - 1.0*(q[i]-cot[c])*(q[i]-cot[c])/79;
      dist += dd < 0.0 ? 0.0 : dd;
    }
    for (c = 0; c < chc; c++) {
      if (cht[c] > q[i])
	continue;
      dd = 8*chq[c] - 1.0*(q[i]-cht[c])/12;
      dist += dd < 0.0 ? 0.0 : dd;
    }
    if (dist <= 1.0) 
      dist = 1.0;
    printf("%d %.1f\n", (int)q[i], dist);
  }
  return 0;
}

